# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: net-mta/net-analyzer/netams/n4agent-4.0.1478.ebuild,v 1.0 2012/08/15 16:35:00 itspec.ru Exp $

EAPI="3"

inherit eutils

DESCRIPTION="Remote Agent For NeTAMS4"
HOMEPAGE="http://www.netams.com"

SRC_URI="x86? ( http://www.netams.com/files/netams4/netams${PV}-linux-i386.tar.gz )
         amd64? ( http://www.netams.com/files/netams4/netams${PV}-linux-x64.tar.gz )
         x86-fbsd? ( http://www.netams.com/files/netams4/netams${PV}-freebsd-i386.tar.gz )
         amd64-fbsd? ( http://www.netams.com/files/netams4/netams${PV}-freebsd-x64.tar.gz )
         "
SLOT="4.0"
LICENSE="netams4-EULA"
RESTRICT="mirror"

KEYWORDS="~x86 ~amd64 ~x86-fbsd ~amd64-fbsd"

IUSE="static"

DEPEND="dev-libs/libevent
        net-libs/libpcap
        static? ( dev-libs/libevent[static-libs] net-libs/libpcap[static-libs] )"

RDEPEND="${DEPEND}"

src_unpack() {
    unpack ${A}
    cd ${WORKDIR}/jserver/agent
    A=./n4agent-src.tar.gz
    unpack ${A}
    S=${WORKDIR}/jserver/agent/src
}

src_prepare() {
    sed -e 's:/usr/local/lib:/usr/lib:' -i ${S}/Makefile
    sed -e 's:/usr/local/include:/usr/include:' -i ${S}/Makefile
    if ! use static; then
        sed -e 's:-static::' -i ${S}/Makefile
    fi
}

src_compile() {
    emake -j1 || die "compile failure"
}

src_install() {
    dosbin n4agent_pcap || die
    dosbin n4ctl || die
    dosbin nfgen || die
    newinitd "${FILESDIR}"/n4agent-init n4agent
    newconfd "${FILESDIR}"/n4agent-conf n4agent
}
